package com.yzr.servlet;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Arrays;
import java.util.Map;
import java.util.Set;

/**
 * @description
 * @author: yx-0173
 * @date: 2021-08-24 15:38
 **/
public class MyServlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("获取请求的资源路径 =" + req.getRequestURI());
        System.out.println("获取请求的资源的全url =" + req.getRequestURL());
        System.out.println("请求方式 =" + req.getMethod());
        System.out.println("客户端的ip地址 =" + req.getRemoteHost());
        System.out.println("请求头 User-Agent 信息 =" + req.getHeader("User-Agent"));
        System.out.println("接收参数 =" + req.getParameterMap());
        Map<String, String[]> parameterMap = req.getParameterMap();
        Set<Map.Entry<String, String[]>> set = parameterMap.entrySet();
        for (Map.Entry<String, String[]> entry : set) {
            System.out.println("接收参数" + Arrays.toString(entry.getValue()));
        }
    }
}
